/**
 * 
 */
$(function(){
	reader.ready=function(){
		reader.voicePrompt.play("/iac/csair/mp3/ymjz");
	};
	$.blockUI({ message: "<h1><a id='msg' href='##' title='提示：页面加载中，请稍后。。。'>提示：页面加载中，请稍后。。。(<span id='countdown'>900</span>)</a></h1>" });
	timedCount();
	
	$.ajax({
		url:'preAssigneeCtrl',
		type:'POST',
		dataType:'json',
		sync: true,
		success:function(data){
			if(data.state == "SUCCESS"){
				$.unblockUI();
				reader.stopAll();
			}else{
				$.unblockUI();
				reader.stopAll();
				window.location.href="index";
			}
			
		}
	});
	
	
	$(".bluebtn").click(function(){
		$.blockUI({ message: "<h1><a id='msg' href='##' title='提示：页面加载中，请稍后。。。'>提示：页面加载中，请稍后。。。(<span id='countdown'>900</span>)</a></h1>" });
		reader.voicePrompt.play("/iac/csair/mp3/ymjz");
		timedCount();
		$.ajax({
			url:'AssigneeCtrlContinue',
			type:'POST',
			dataType:'json',
			sync: true,
			success:function(data){
				if(data.state == "SUCCESS"){
					if(data.checkmodel == true){
						$.unblockUI();
						reader.stopAll();
						var contentHtml = data.map.dialogDivContent;
						$(".check_ticket_body").html(contentHtml);
						$("div.ui-helper-clearfix").remove();
						checkout();
					}
				}
				if(data.state == "SUCCESS"){
					if(data.checkmodel == false){
						$.unblockUI();
						reader.stopAll();
						$("#content").attr("style","display:none;");
						$("#content1").attr("style","display:block;");
						$("div.table").html(data.map.table);
						$("#countdown").remove();
						$("input").removeAttr("onblur");
					}
				}
				if(data.state == "FAIL"){
					$.unblockUI();
					reader.stopAll();
					alert("校验框加载失败!")
					$("#countdown").remove();
				}
			}
		});
	})
	
	$(".savebtn").click(function(){
		var $this = $(this);
		var firstNameCN1 = $("#firstNameCN1").val();
		var lastNameCN1 = $("#lastNameCN1").val();
		var firstNameEN1 = $("#firstNameEN1").val();
		var lastNameEN1 = $("#lastNameEN1").val();
		var inputcertificateIdnum1 = $("#inputcertificateIdnum1").val();
		var inputpassport1 = $("#inputpassport1").val();
		var inputotherCertificate1 = $("#inputotherCertificate1").val();
		
		var firstNameCN2 = $("#firstNameCN2").val();
		var lastNameCN2 = $("#lastNameCN2").val();
		var firstNameEN2 = $("#firstNameEN2").val();
		var lastNameEN2 = $("#lastNameEN2").val();
		var inputcertificateIdnum2 = $("#inputcertificateIdnum2").val();
		var inputpassport2 = $("#inputpassport2").val();
		var inputotherCertificate2 = $("#inputotherCertificate2").val();
		
		var firstNameCN3 = $("#firstNameCN3").val();
		var lastNameCN3 = $("#lastNameCN3").val();
		var firstNameEN3 = $("#firstNameEN3").val();
		var lastNameEN3 = $("#lastNameEN3").val();
		var inputcertificateIdnum3 = $("#inputcertificateIdnum3").val();
		var inputpassport3 = $("#inputpassport3").val();
		var inputotherCertificate3 = $("#inputotherCertificate3").val();
		
		var firstNameCN4 = $("#firstNameCN4").val();
		var lastNameCN4 = $("#lastNameCN4").val();
		var firstNameEN4 = $("#firstNameEN4").val();
		var lastNameEN4 = $("#lastNameEN4").val();
		var inputcertificateIdnum4 = $("#inputcertificateIdnum4").val();
		var inputpassport4 = $("#inputpassport4").val();
		var inputotherCertificate4 = $("#inputotherCertificate4").val();
		
		var firstNameCN5 = $("#firstNameCN5").val();
		var lastNameCN5 = $("#lastNameCN5").val();
		var firstNameEN5 = $("#firstNameEN5").val();
		var lastNameEN5 = $("#lastNameEN5").val();
		var inputcertificateIdnum5 = $("#inputcertificateIdnum5").val();
		var inputpassport5 = $("#inputpassport5").val();
		var inputotherCertificate5 = $("#inputotherCertificate5").val();
		
		var firstNameCN6 = $("#firstNameCN6").val();
		var lastNameCN6 = $("#lastNameCN6").val();
		var firstNameEN6 = $("#firstNameEN6").val();
		var lastNameEN6 = $("#lastNameEN6").val();
		var inputcertificateIdnum6 = $("#inputcertificateIdnum6").val();
		var inputpassport6 = $("#inputpassport6").val();
		var inputotherCertificate6 = $("#inputotherCertificate6").val();
		
		var firstNameCN7 = $("#firstNameCN7").val();
		var lastNameCN7 = $("#lastNameCN7").val();
		var firstNameEN7 = $("#firstNameEN7").val();
		var lastNameEN7 = $("#lastNameEN1").val();
		var inputcertificateIdnum7 = $("#inputcertificateIdnum7").val();
		var inputpassport7 = $("#inputpassport7").val();
		var inputotherCertificate7 = $("#inputotherCertificate7").val();
		
		var firstNameCN8 = $("#firstNameCN8").val();
		var lastNameCN8 = $("#lastNameCN8").val();
		var firstNameEN8 = $("#firstNameEN8").val();
		var lastNameEN8 = $("#lastNameEN8").val();
		var inputcertificateIdnum8 = $("#inputcertificateIdnum8").val();
		var inputpassport8 = $("#inputpassport8").val();
		var inputotherCertificate8 = $("#inputotherCertificate8").val();
		
		reader.ready=function(){
			reader.voicePrompt.play("/iac/csair/mp3/00004");
		};
		$.blockUI({ message: "<h1><a id='msg' href='#' title='提示：正在加载页面信息，请稍后。。。'>提示：正在加载页面信息，请稍后。。。(<span id='countdown'>900</span>)</a></h1>" });
		timedCount();
		$.ajaxSetup({ cache:false });
		$.ajax({
			url : 'AssigneeCtrlSave',
			type : 'POST',
			dataType:'JSON',
			sync : true,
			data : {
				 "firstNameCN1":firstNameCN1 ,
				 "lastNameCN1":lastNameCN1,
				 "firstNameEN1":firstNameEN1,
				 "lastNameEN1":lastNameEN1,
				 "inputcertificateIdnum1":inputcertificateIdnum1,
				 "inputpassport1":inputpassport1,
				 "inputotherCertificate1":inputotherCertificate1,
				 
				 "firstNameCN2":firstNameCN2 ,
				 "lastNameCN2":lastNameCN2,
				 "firstNameEN2":firstNameEN2,
				 "lastNameEN2":lastNameEN2,
				 "inputcertificateIdnum2":inputcertificateIdnum2,
				 "inputpassport2":inputpassport2,
				 "inputotherCertificate2":inputotherCertificate2,
				 
				 "firstNameCN3":firstNameCN3 ,
				 "lastNameCN3":lastNameCN3,
				 "firstNameEN3":firstNameEN3,
				 "lastNameEN3":lastNameEN3,
				 "inputcertificateIdnum3":inputcertificateIdnum3,
				 "inputpassport3":inputpassport3,
				 "inputotherCertificate3":inputotherCertificate3,
				 
				 "firstNameCN4":firstNameCN4 ,
				 "lastNameCN4":lastNameCN4,
				 "firstNameEN4":firstNameEN4,
				 "lastNameEN4":lastNameEN4,
				 "inputcertificateIdnum4":inputcertificateIdnum4,
				 "inputpassport4":inputpassport4,
				 "inputotherCertificate4":inputotherCertificate4,
				 
				 "firstNameCN5":firstNameCN5 ,
				 "lastNameCN5":lastNameCN5,
				 "firstNameEN5":firstNameEN5,
				 "lastNameEN5":lastNameEN5,
				 "inputcertificateIdnum5":inputcertificateIdnum5,
				 "inputpassport5":inputpassport5,
				 "inputotherCertificate5":inputotherCertificate5,
				 
				 "firstNameCN6":firstNameCN6 ,
				 "lastNameCN6":lastNameCN6,
				 "firstNameEN6":firstNameEN6,
				 "lastNameEN6":lastNameEN6,
				 "inputcertificateIdnum6":inputcertificateIdnum6,
				 "inputpassport6":inputpassport6,
				 "inputotherCertificate6":inputotherCertificate6,
				 
				 "firstNameCN7":firstNameCN7 ,
				 "lastNameCN7":lastNameCN7,
				 "firstNameEN7":firstNameEN7,
				 "lastNameEN7":lastNameEN7,
				 "inputcertificateIdnum7":inputcertificateIdnum7,
				 "inputpassport7":inputpassport7,
				 "inputotherCertificate7":inputotherCertificate7,
				 
				 "firstNameCN8":firstNameCN8 ,
				 "lastNameCN8":lastNameCN8,
				 "firstNameEN8":firstNameEN8,
				 "lastNameEN8":lastNameEN8,
				 "inputcertificateIdnum8":inputcertificateIdnum8,
				 "inputpassport8":inputpassport8,
				 "inputotherCertificate8":inputotherCertificate8
			},
			success : function(data) {
				if(data.state == "SUCCESS"){
					$.unblockUI();
					reader.stopAll();
					navBlock.init();
					var top = $this.offset().top+$this.height();
					var left = $this.offset().left;
					$("#assigneeCtrlxx").html(data.map.twiceCheck);
					$("#assigneeCtrlxx").attr("style","display:block; float:left; position:absolute;  margin-left:"+left+"px; margin-top:"+top+"px; top:10px");
					
				}else{
					alert(data.message)
					$.unblockUI();
					reader.stopAll();
					navBlock.init();
				}
			}
		});
	}) 

	$("input[value='取消']").click(function(){
		reader.ready=function(){
			reader.voicePrompt.play("/iac/csair/mp3/00004");
		};
		$.blockUI({ message: "<h1><a id='msg' href='#' title='提示：正在加载页面信息，请稍后。。。'>提示：正在加载页面信息，请稍后。。。(<span id='countdown'>900</span>)</a></h1>" });
		timedCount();
		$.ajax({
			url:'AssigneeTwiceCheckQuit',
			type:'POST',
			dataType:'json',
			sync: true,
			success:function(data){
				if(data.state == "SUCCESS"){
					$.unblockUI();
					reader.stopAll();
					$("#assigneeCtrlxx").html(data.map.twiceCheck);
					$("#assigneeCtrlxx").attr("style","display:none;");
				}else{
					$.unblockUI();
					reader.stopAll();
					alert("点击取消失败!")
				}
			}
		});
	})
	
	
	$("input[value='确认']").click(function(){
		reader.ready=function(){
			reader.voicePrompt.play("/iac/csair/mp3/00004");
		};
		$.blockUI({ message: "<h1><a id='msg' href='#' title='提示：正在加载页面信息，请稍后。。。'>提示：正在加载页面信息，请稍后。。。(<span id='countdown'>900</span>)</a></h1>" });
		timedCount();
		$.ajax({
			url:'AssigneeTwiceCheckBtn',
			type:'POST',
			dataType:'json',
			sync: true,
			success:function(data){
				if(data.state == "SUCCESS"){
					$.unblockUI();
					reader.stopAll();
					alert(data.message)
					$("#assigneeCtrlxx").html("");
					$("#assigneeCtrlxx").attr("style","display:none;");
				}else{
					$.unblockUI();
					reader.stopAll();
					alert("点击确认失败!")
				}
			}
		});
	})
	
})

function checkout(){
		$.blockUI({ message: $('.check_box_div') });
		$("#countdown").remove();
		$("#emailTile").remove();
		$("#code").focus();
		$(".check_ticket_body  table tr td[align=right]").attr("align","center");
		$(".check_ticket_body  table tr td a[style='color:blue']").attr("onclick","");
		$(".check_ticket_body  table tr td a[style='color:blue']").attr("href","preCsairOnlineIdentityAuthentication");
		$("#sendCode").attr("href","javascript:assigneeCtrlYzm();");
		$("#vaildCode").attr("href","javascript:assigneeCtrlCheck();");
	}

function assigneeCtrlYzm(){
	$.ajax({
		url:'AssigneeCtrlYzm',
		type:'POST',
		dataType:'json',
		sync: true,
		success:function(data){
			alert(data.message)
		}
	});
}

function assigneeCtrlCheck(){
	var yzm = $("#code").val();
	if(yzm == null || yzm ==""){
		alert("请填写验证码!")
		return;
	}
	$.blockUI({ message: "<h1><a id='msg' href='##' title='提示：页面加载中，请稍后。。。'>提示：页面加载中，请稍后。。。(<span id='countdown'>900</span>)</a></h1>" });
	reader.voicePrompt.play("/iac/csair/mp3/ymjz");
	timedCount();
	$.ajax({
		url:'AssigneeCtrlCheck',
		type:'POST',
		data:{"yzm":yzm},
		dataType:'json',
		sync: true,
		success:function(data){
			if(data.state == "SUCCESS"){
				$("#content").attr("style","display,none;");
				$("#content1").attr("style","display,block;");
				$("#table").html(data.map.table);
			}else{
				$.unblockUI();
				reader.stopAll();
				alert(data.message)
				$("#countdown").remove();
			}
		}
	});
}

